﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Data.SqlClient;

namespace SKG.DXF.Ktx.Report
{
    public partial class FrmRp_Tienphong : DevExpress.XtraEditors.XtraForm
    {
        public Guid _phongID;

        public FrmRp_Tienphong()
        {
            InitializeComponent();
        }

        private void FrmRp_Tienphong_Load(object sender, EventArgs e)
        {

            XRTienphong xr = new XRTienphong();
            xr.parameter1.Value = DateTime.Now;
            xr.DataSource = LoadData();
            xr.DataBingdings();

            printControl1.PrintingSystem = xr.PrintingSystem;
            xr.CreateDocument();
        }

        private DataSet LoadData()
        {
            SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=KTX_14;Persist Security Info=True;User ID=sa;Password=123456");
            conn.Open();
            SqlCommand cmd = new SqlCommand(@"Select a.Sophieu,a.Ngaythu,b.Maphong,a.Sotien,a.Bangchu
                                              From Ktx_Tienphong a join Ktx_Phong b on a.PhongId=b.Id
                                              Where b.Id = '"+_phongID+"' ", conn);
            DataSet ds = new DataSet();
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            da.Fill(ds);
            return ds;
        }

    }
}